var ajaxHelper = require("../../utils/ajaxhelp");
let token = wx.getStorageSync('token');
const serviceUrl = getApp().globalData.serviceUrl;

const QueryLeadPageByConditions = (condition, pageNum, pageSize) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Lead/QueryLeadPageByConditions", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		condition: condition,
		pageNum: pageNum,
		pageSize: pageSize,
	})
}

const QueryLeadPageByScreenStat = (searchKey,pageNum,pageSize,ownerid,screenteamid,startdate,enddate,type)=>{
  token = wx.getStorageSync('token');
  return ajaxHelper.promiseRequst(serviceUrl + "/api/Lead/QueryLeadPageByScreenStat", {
    'Authorization': 'Bearer ' + token
  }, "GET", {
      searchKey: searchKey,
      pageNum: pageNum,
      pageSize: pageSize,
      ownerid: ownerid,
      screenteamid: screenteamid,
      startdate: startdate,
      enddate:enddate,
      type:type
    })
}

const QueryLeadPageByConditionsAndOwner = (condition, pageNum, pageSize,ownerid) => {
  token = wx.getStorageSync('token');
  return ajaxHelper.promiseRequst(serviceUrl + "/api/Lead/QueryLeadPageByConditionsAndOwner", {
    'Authorization': 'Bearer ' + token
  }, "GET", {
      condition: condition,
      pageNum: pageNum,
      pageSize: pageSize,
      ownerid: ownerid
    })
}

const GetAcountDetailsData = (leadId) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Lead/GetAcountDetailsData", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		leadId: leadId
	})
}

const GetAccountScreenDetailData = (leadId, screenId) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Lead/GetAccountScreenDetailData", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		leadId: leadId,
		screenId: screenId
	})
}

//分组显示班级内学生
const GetLeadInfoBySchoolIdAndClassNum = (classId, schoolId = '') => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Lead/QueryLeadInfoBySchoolIdAndClassNum", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		classId: classId,
		schoolId: schoolId
	})
}

//根据leadid查询lead信息
const QueryLeadInfoById = (leadId) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Lead/QueryLeadInfoById", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		leadId: leadId
	})
}

const QueryStudentInfoById = (leadId) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Lead/QueryStudentInfoById", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		leadId: leadId
	})
}


module.exports = {
	QueryLeadPageByConditions,
  QueryLeadPageByConditionsAndOwner,
	QueryLeadInfoById,
	GetAcountDetailsData,
	GetAccountScreenDetailData,
	GetLeadInfoBySchoolIdAndClassNum,
	QueryStudentInfoById,
  QueryLeadPageByScreenStat
}
